'''
Created on 14. jan. 2010

@author: perfp
'''
import unittest
from CheckoutModule import Checkout

class Test(unittest.TestCase):

    
    def setUp(self):
        self.rules = [("A", 100, (2, 150)), ("B", 120, (2, 200)), ("C", 40, None), ("D", 60, None)]
    


    def tearDown(self):
        pass


    def testIncremental(self):
        
        checkout = Checkout(self.rules)
        
        checkout.Scan("A")
        self.assertEqual(100, checkout.Total)
        
        checkout.Scan("B")
        self.assertEqual(220, checkout.Total)

    def testMultipleRegistrations(self):
        checkout = Checkout(self.rules)
        checkout.Scan("ABC")
        self.assertEqual(260, checkout.Total)
        
    def testSpecialOffer(self):
        checkout = Checkout(self.rules)
        checkout.Scan("AA")
        self.assertEqual(150, checkout.Total)
        
    def testAllCombos(self):
        checkout = Checkout(self.rules)
        checkout.Scan("ABABCDBA")
        self.assertEqual(670, checkout.Total)

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()